package org.dreamfly.core.util;

/**
 * Created by IntelliJ IDEA.
 * User: Gin
 * Date: 2010-12-5
 * Time: 0:41:12
 * To change this template use File | Settings | File Templates.
 */
import javax.servlet.http.HttpSession;
import java.util.HashMap;

public final class SessionContext {
    private static final SessionContext instance = new SessionContext();
    private HashMap mymap;

    private SessionContext() {
        mymap = new HashMap();
    }

    public static SessionContext getInstance() {

        return instance;
        //TODO
    }

    public synchronized void AddSession(HttpSession session) {
        if (session != null) {
            mymap.put(session.getId(), session);
        }
    }

    public synchronized void DelSession(HttpSession session) {
        if (session != null) {
            mymap.remove(session.getId());
        }
    }

    public synchronized HttpSession getSession(String session_id) {
        if (session_id == null) return null;
        return (HttpSession) mymap.get(session_id);
    }

}
